Skip to content

opentelemetry-exporter-otlp-json-http: add OTLP JSON HTTP exporter#5374

Open
herin049 wants to merge 31 commits into
open-telemetry:mainfrom
herin049:feat/otlp-json-exporter
Open

opentelemetry-exporter-otlp-json-http: add OTLP JSON HTTP exporter#5374
herin049 wants to merge 31 commits into
open-telemetry:mainfrom
herin049:feat/otlp-json-exporter

Conversation

@herin049

@herin049 herin049 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Description

Final PR to implement the OTLP JSON exporter.

Fixes #1003

Because of the addition of the new opentelemetry-exporter-otlp-common and opentelemetry-exporter-http-transport packages, the exporter implementations themselves are only a few hundred lines of code - most of which is just parameter passing/forwarding. However, I did emphasize trying to make the unit tests as exhaustive and robust as possible, which is why the diff in this PR is so large.

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

uv run tox -e py314-test-opentelemetry-exporter-otlp-json-http

Does This PR Require a Contrib Repo Change?

  • Yes. - Link to PR:
  • No.

Checklist:

  • Followed the style guidelines of this project
  • Changelogs have been updated
  • Unit tests have been added
  • Documentation has been updated

@herin049 herin049 added Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary exporters labels Jul 1, 2026
@aabmass

aabmass commented Jul 1, 2026

Copy link
Copy Markdown
Member

Is this blocked on any other PRs?

@herin049

herin049 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Is this blocked on any other PRs?

@aabmass

Technically not a hard block, but I'd like to get #5220 in before this PR so I can add more robust/exhaustive Docker tests using the collector for the new exporter. I want to test several different types of configurations while performing round-trip verification.

Likewise, I've identified an issue with the way we previously introduced the exporter metrics, which is that we currently depend on the incubating portion of the semconv packag. This is very bad for maintaining compatibility with newer SDKs, so I am going to open a PR to fix that, but that can come later.

@herin049

herin049 commented Jul 1, 2026

Copy link
Copy Markdown
Contributor Author

Is this blocked on any other PRs?

@aabmass

Technically not a hard block, but I'd like to get #5220 in before this PR so I can add more robust/exhaustive Docker tests using the collector for the new exporter. I want to test several different types of configurations while performing round-trip verification.

Likewise, I've identified an issue with the way we previously introduced the exporter metrics, which is that we currently depend on the incubating portion of the semconv packag. This is very bad for maintaining compatibility with newer SDKs, so I am going to open a PR to fix that, but that can come later.

I'm leaving this in draft since I still need to polish the PR a bit more (mostly adding tests) before sending it out for reviews.

@herin049
herin049 marked this pull request as ready for review July 2, 2026 04:26
@herin049
herin049 requested a review from a team as a code owner July 2, 2026 04:26

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds a new opentelemetry-exporter-otlp-json-http package to the OpenTelemetry Python monorepo, providing OTLP JSON-over-HTTP exporters for traces, metrics, and logs (addressing #1003), along with CI, docs, and extensive unit tests.

Changes:

  • Introduces a new OTLP JSON HTTP exporter package (trace/metric/log exporters) plus internal configuration/transport resolution.
  • Adds metric request splitting support in the OTLP JSON common encoder and corresponding tests.
  • Wires the new package into the workspace, tox/CI matrices, distribution lists, and Sphinx docs.

Reviewed changes

Copilot reviewed 32 out of 34 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
uv.lock Adds the new exporter package to the workspace lock and dependency graph.
tox.ini Adds test/lint envs and editable installs for the new exporter package.
pyproject.toml Adds the new exporter to workspace dependencies and build include/exclude lists.
exporter/opentelemetry-exporter-otlp-json-http/tests/test_trace_exporter.py Trace exporter unit tests for request formation, env/config, retries, compression, shutdown behavior.
exporter/opentelemetry-exporter-otlp-json-http/tests/test_metric_exporter.py Metric exporter unit tests including batch splitting, retries, compression, shutdown behavior.
exporter/opentelemetry-exporter-otlp-json-http/tests/test_log_exporter.py Log exporter unit tests for request formation, env/config, retries, compression, shutdown behavior.
exporter/opentelemetry-exporter-otlp-json-http/tests/test_internal.py Tests for internal endpoint/header/timeout/compression/transport resolution helpers.
exporter/opentelemetry-exporter-otlp-json-http/tests/init.py Shared test helper for mocking time/backoff behavior.
exporter/opentelemetry-exporter-otlp-json-http/test-requirements.txt Test dependencies and editable installs for the new exporter package.
exporter/opentelemetry-exporter-otlp-json-http/src/opentelemetry/exporter/otlp/json/http/version/init.py Declares package version for hatch versioning.
exporter/opentelemetry-exporter-otlp-json-http/src/opentelemetry/exporter/otlp/json/http/trace_exporter.py Implements OTLP JSON HTTP span exporter using shared OTLP HTTP client/transport.
exporter/opentelemetry-exporter-otlp-json-http/src/opentelemetry/exporter/otlp/json/http/py.typed Marks the package as typed for downstream type checkers.
exporter/opentelemetry-exporter-otlp-json-http/src/opentelemetry/exporter/otlp/json/http/metric_exporter.py Implements OTLP JSON HTTP metric exporter, including optional request splitting.
exporter/opentelemetry-exporter-otlp-json-http/src/opentelemetry/exporter/otlp/json/http/_log_exporter.py Implements OTLP JSON HTTP log exporter.
exporter/opentelemetry-exporter-otlp-json-http/src/opentelemetry/exporter/otlp/json/http/_internal.py Implements env var resolution + transport construction for the JSON HTTP exporters.
exporter/opentelemetry-exporter-otlp-json-http/src/opentelemetry/exporter/otlp/json/http/init.py Package docstring and public re-exports.
exporter/opentelemetry-exporter-otlp-json-http/README.rst New package README for installation and references.
exporter/opentelemetry-exporter-otlp-json-http/pyproject.toml Package metadata, dependencies, and entry points for traces/metrics/logs exporters.
exporter/opentelemetry-exporter-otlp-json-http/LICENSE Adds Apache 2.0 license file for the new package.
exporter/opentelemetry-exporter-otlp-json-file/test-requirements.txt Adds opentelemetry-exporter-otlp-common to test editable installs for json-file exporter.
exporter/opentelemetry-exporter-otlp-json-file/src/opentelemetry/exporter/otlp/json/file/metric_exporter.py Updates metric exporter to use aggregation/temporality helpers from the new common OTLP package.
exporter/opentelemetry-exporter-otlp-json-file/pyproject.toml Adds dependency on opentelemetry-exporter-otlp-common.
exporter/opentelemetry-exporter-otlp-json-common/tests/test_metrics_split.py Adds thorough tests for metric request splitting behavior.
exporter/opentelemetry-exporter-otlp-json-common/tests/test_common_encoder.py Removes temporality/aggregation tests moved out of json-common internals.
exporter/opentelemetry-exporter-otlp-json-common/src/opentelemetry/exporter/otlp/json/common/_internal/metrics_encoder/init.py Adds metric splitting implementation and helper constants/functions.
exporter/opentelemetry-exporter-otlp-json-common/src/opentelemetry/exporter/otlp/json/common/_internal/init.py Removes temporality/aggregation helpers moved into opentelemetry-exporter-otlp-common.
exporter/opentelemetry-exporter-otlp-common/src/opentelemetry/exporter/otlp/common/init.py Re-exports Compression from the common OTLP HTTP module.
exporter/opentelemetry-exporter-http-transport/src/opentelemetry/exporter/http/transport/_base.py Fixes a docstring grammar issue (“exception if …”).
eachdist.ini Adds the new exporter package to per-package distribution configuration.
docs/exporter/otlp/otlp.rst Adds Sphinx API docs sections for the new JSON HTTP exporter modules.
docs/conf.py Adds Sphinx nitpick ignores for private-module-resolved type hints used by new exporter.
.github/workflows/test.yml Adds CI test jobs for the new exporter across supported CPython/PyPy versions and OSes.
.github/workflows/lint.yml Adds CI lint job for the new exporter package.
.changelog/5374.added Adds changelog entry announcing the new exporter package.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@herin049 herin049 moved this to Ready for review in Python PR digest Jul 2, 2026
Comment thread exporter/opentelemetry-exporter-otlp-json-http/README.rst
Comment thread exporter/opentelemetry-exporter-otlp-json-http/README.rst Outdated
Comment thread exporter/opentelemetry-exporter-otlp-json-http/README.rst Outdated
Comment thread exporter/opentelemetry-exporter-otlp-json-http/tests/__init__.py Outdated
shutdown_event = self._mocked_shutdown_event()
exporter._client._shutdown_event = shutdown_event

with _mock_clock(shutdown_event):

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't follow why this is necessary or what it is doing, none of the unit tests using mock_clock are testing or relying on the shutdown behavior AFAICT

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is used inside the OTLPHTTPClient. The primary reason I'm using it here is to avoid wasting wall clock time sleeping inside of the backoff-retry loop.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ok makes sense.. maybe add a comment on the mock_clock function explaining this

def get_time() -> float:
return _now

if shutdown_event is not None:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: seems like shutdown_event is always passed in, so we don't need this check ?

@@ -97,7 +97,7 @@ def from_str(value: str) -> Compression:


@dataclass(slots=True, frozen=True)
class ExportResult:

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems like we are making a private module public and making public symbols in that module private. I'm curious about the motivation behind these changes.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It's a little hard to see, but it is to make Compression public. I found it easier to just do it this way.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Approve Public API check This label shows that the public symbols added or changed in a PR are strictly necessary exporters

Projects

Status: Ready for review

Development

Successfully merging this pull request may close these issues.

Support JSON over HTTP in OTLP exporter

5 participants